22010 18: 40: 39 "use strict";
var imgBox = document.querySelector(".imgBox"),
    bannerBox = document.querySelector(".banner"),
    pointBox = document.querySelector(".pointBox"),
    flag = !0;

function copyEle() {
    var e = imgBox.firstElementChild.cloneNode(!0),
        n = imgBox.lastElementChild.cloneNode(!0);
    imgBox.appendChild(e), imgBox.insertBefore(n,
            imgBox.firstElementChild),
        imgBox.style.width = 100 * imgBox.children.length + "%",
        imgBox.style.left = -1 * bannerBox.clientWidth + "px"
}

function setPoint() {
    for (var e = imgBox.children.length - 2, n = 0; n < e; n++) {
        var i = document.createElement("li");
        i.classList.add("item"),
            i.dataset.point = n,
            pointBox.appendChild(i),
            0 === n && i.classList.add("active")
    }
    pointBox.style.width = 24 * e + "px"
}
copyEle(),
    setPoint();
var index = 1,
    time = 0;

function autoPlay() {
    time = setInterval(function() {
        !1 !== flag && (flag = !1, index++, move(imgBox, { left: -index * bannerBox.clientWidth }, moveEnd))
    }, 4e3)
}

function moveEnd() {
    index === imgBox.children.length - 1 && (index = 1, imgBox.style.left = -index * bannerBox.clientWidth + "px"),
        0 === index && (index = imgBox.children.length - 2, imgBox.style.left = -index * bannerBox.clientWidth + "px");
    for (var e = 0; e < pointBox.children.length; e++) pointBox.children[e].classList.remove("active");
    pointBox.children[index - 1].classList.add("active"),
        flag = !0
}

function overOut() {
    bannerBox.onmouseover = function() {
        clearInterval(time)
    }, bannerBox.onmouseout = function() {
        autoPlay()
    }
}

function clickChange() {
    bannerBox.onclick = function(e) {
        e = (e = e || window.event).target || e.srcElement;
        if ("left" === e.className) {
            if (!1 === flag) return;
            flag = !1, index--, move(imgBox, {
                left: -index * bannerBox.clientWidth
            }, moveEnd)
        }
        if ("right" === e.className) {
            if (!1 === flag) return;
            flag = !1, index++, move(imgBox, {
                left: -index * bannerBox.clientWidth
            }, moveEnd)
        }
        "item" === e.className && !1 !== flag && (flag = !1, index = +e.dataset.point + 1, move(imgBox, {
            left: -index * bannerBox.clientWidth
        }, moveEnd))
    }
}

function tabChange() {
    document.onvisibilitychange = function() {
        "hidden" === document.visibilityState && clearInterval(time),
            "visible" === document.visibilityState && autoPlay()
    }
}
autoPlay(),
    moveEnd(),
    overOut(),
    clickChange(),
    tabChange();